<?php

namespace Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\MappedSuperclass
 */
class MappedSuperclassBase
{

    /**
     * @var integer
     * @ORM\Column(type="integer")
     * @ORM\Id 
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    function __construct(array $data = null)
    {
        if ($data){
            $this->appendData($data);
        }
    }


    public function getId()
    {
        return $this->id;
    }
    
    public function appendData(array $data)
    {
        foreach ($data as $field => $value) {
            $method = "set".ucfirst($field);
            if (method_exists($this, $method)){
                $this->$method($value);
            }
        }
    }

}
